﻿@model NeverSoldReportModel
@using Telerik.Web.Mvc.UI
@{
    var gridPageSize = EngineContext.Current.Resolve<Nop.Core.Domain.Common.AdminAreaSettings>().GridPageSize;
}
@using (Html.BeginForm())
{
    <div class="section-header">
        <div class="title">
            <img src="@Url.Content("~/Administration/Content/images/ico-sales.png")" alt="" />
            @T("Admin.SalesReport.NeverSold")
        </div>
        <div class="options">
        </div>
    </div>
    <table width="100%">
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.StartDate):
            </td>
            <td class="adminData">
                @Html.EditorFor(model => model.StartDate)
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.EndDate):
            </td>
            <td class="adminData">
                @Html.EditorFor(model => Model.EndDate)
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <button type="submit" id="btnSearch" class="t-button">@T("Admin.SalesReport.NeverSold.RunReport")</button>
            </td>
        </tr>
    </table>
     <p>
    </p>
    <table class="adminContent">
        <tr>
            <td>
                @(Html.Telerik().Grid<BestsellersReportLineModel>()
                        .Name("neversoldreport-grid")
                        .ClientEvents(events => events.OnDataBinding("onDataBinding"))
                        .Columns(columns =>
                        {
                            columns.Bound(x => x.ProductVariantFullName);
                            columns.Bound(x => x.ProductVariantId)
                                .Template(x => Html.ActionLink(@T("Admin.Common.View").Text, "Edit", "ProductVariant", new { id = x.ProductVariantId }, new { }))
                                .ClientTemplate("<a href=\"" + @Url.Content("~/Admin/ProductVariant/Edit/") + "<#= ProductVariantId #>\">" + T("Admin.Common.View").Text + "</a>")
                                .Width(50)
                                .Centered()
                                .Title(T("Admin.Common.View").Text);
                        })
                        .Pageable(settings => settings.PageSize(gridPageSize).Position(GridPagerPosition.Both))
                        .DataBinding(dataBinding => dataBinding.Ajax().Select("NeverSoldReportList", "Order"))
                        .EnableCustomBinding(true))
            </td>
        </tr>
    </table>
    
    <script type="text/javascript">

        $(document).ready(function () {

            $('#btnSearch').click(function () {
                var grid = $('#neversoldreport-grid').data('tGrid');
                grid.currentPage = 1; //new search. Set page size to 1
                grid.ajaxRequest();
                return false;
            });

        });

    function onDataBinding(e) {
        var searchModel = {
                StartDate: $('#@Html.FieldIdFor(model => model.StartDate)').val(),
                EndDate: $('#@Html.FieldIdFor(model => model.EndDate)').val()
                };
        e.data = searchModel;
    }

   </script>
    
}